$(function () {
    //提交评分
    $("#true").click(function () {
        var tmp = "__SITE__/index/Index/addScore";
        alert(tmp);
        if(checkmusic() && checkskill() && checkfluency() && checkvoice() && checkattach()) {
            var music = $("#music").val();
            var skill = $("#skill").val();
            var fluency = $("#fluency").val();
            var voice = $("#voice").val();
            var attach = $("#attach").val();
            // $("#true").attr('disabled',true);
            $.ajax({
                url:"__SITE__/index/Index/addScore",
                data:{
                    music:music,
                    skill:skill,
                    fluency:fluency,
                    voice:voice,
                    attach:attach,
                    // openid:"{:session('openid')}"
                },
                type:'POST',
                dataType:'json',
                success:function (data) {

                }
            });
        }
    });

    //检测乐感理解
    function checkmusic()
    {
        var item = $("#music").val();
        if(!item) {
            $("#music").css("border","1px solid red");
            return false;
        }
        var tag = /^[0-9]*$/;
        if(!tag.test($("#music").val())) {
            $("#music").css("border","1px solid red");
            return false;
        }
        var v = $("#music").val();
        if(v > 50) {
            $("#music").css("border","1px solid red");
            return false;
        }
        $("#music").css('border','1px solid #A9A9A9');
        return true;
    }
    $("#music").blur(function () {
        checkmusic();
    });

    //检测技巧掌握
    function checkskill()
    {
        var item = $("#skill").val();
        if(!item) {
            $("#skill").css("border","1px solid red");
            return false;
        }
        var tag = /^[0-9]*$/;
        if(!tag.test($("#skill").val())) {
            $("#skill").css("border","1px solid red");
            return false;
        }
        var v = $("#skill").val();
        if(v > 50) {
            $("#skill").css("border","1px solid red");
            return false;
        }
        $("#skill").css('border','1px solid #A9A9A9');
        return true;
    }
    $("#skill").blur(function () {
        checkskill();
    });

    //检测曲目流畅
    function checkfluency()
    {
        var item = $("#fluency").val();
        if(!item) {
            $("#fluency").css("border","1px solid red");
            return false;
        }
        var tag = /^[0-9]*$/;
        if(!tag.test($("#fluency").val())) {
            $("#fluency").css("border","1px solid red");
            return false;
        }
        var v = $("#fluency").val();
        if(v > 50) {
            $("#fluency").css("border","1px solid red");
            return false;
        }
        $("#fluency").css('border','1px solid #A9A9A9');
        return true;
    }
    $("#fluency").blur(function () {
        checkfluency();
    });

    //检测音色控制
    function checkvoice()
    {
        var item = $("#voice").val();
        if(!item) {
            $("#voice").css("border","1px solid red");
            return false;
        }
        var tag = /^[0-9]*$/;
        if(!tag.test($("#voice").val())) {
            $("#voice").css("border","1px solid red");
            return false;
        }
        var v = $("#voice").val();
        if(v > 50) {
            $("#voice").css("border","1px solid red");
            return false;
        }
        $("#voice").css('border','1px solid #A9A9A9');
        return true;
    }
    $("#voice").blur(function () {
        checkvoice();
    });

    //检测音乐素养
    function checkattach()
    {
        var item = $("#attach").val();
        if(!item) {
            $("#attach").css("border","1px solid red");
            return false;
        }
        var tag = /^[0-9]*$/;
        if(!tag.test($("#attach").val())) {
            $("#attach").css("border","1px solid red");
            return false;
        }
        var v = $("#attach").val();
        if(v > 50) {
            $("#attach").css("border","1px solid red");
            return false;
        }
        $("#attach").css('border','1px solid #A9A9A9');
        return true;
    }
    $("#attach").blur(function () {
        checkattach();
    });
})